import {reactive, onMounted, onBeforeUnmount} from 'vue'

export default function () {

  let point = reactive({
    x: 0,
    y: 0
  })

  const savePoint = (event) => {
    point.x = event.pageX
    point.y = event.pageY
  }

  onMounted(() => {
    document.addEventListener('click', savePoint)
  })

  onBeforeUnmount(() => {
    document.removeEventListener('click', savePoint)
  })

  return {
    point
  }
}